<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:wpf="clr-namespace:ViewOnCore.Helper.WPF"
  mc:Ignorable="PresentationOptions">

	<DrawingBrush
	  x:Key="CheckerBrush"
	  Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile">
		<DrawingBrush.Drawing>
			<DrawingGroup>
				<GeometryDrawing Brush="White">
					<GeometryDrawing.Geometry>
						<RectangleGeometry Rect="0,0 100,100" />
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
				<GeometryDrawing Brush="LightGray">
					<GeometryDrawing.Geometry>
						<GeometryGroup>
							<RectangleGeometry Rect="0,0 50,50" />
							<RectangleGeometry Rect="50,50 50,50" />
						</GeometryGroup>
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
			</DrawingGroup>
		</DrawingBrush.Drawing>
	</DrawingBrush>

	<!-- Spectrum Slider Styles -->
	<Style x:Key="SliderRepeatButtonStyle"
		   TargetType="{x:Type RepeatButton}">
		<Setter Property="OverridesDefaultStyle"
				Value="true"/>
		<Setter Property="IsTabStop"
				Value="false"/>
		<Setter Property="Focusable"
				Value="false"/>
		<Setter Property="Background"
				Value="Transparent"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Border Background="{TemplateBinding Background}"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="{x:Type wpf:ColorThumb}" TargetType="{x:Type wpf:ColorThumb}">
		<Setter Property="PointerOutlineBrush" Value="Black" />
		<Setter Property="PointerOutlineThickness" Value="1" />
		<Setter Property="Foreground" Value="{x:Null}"/>
		<Setter Property="ThumbColor" Value="Transparent" />
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="Height" Value="4"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type wpf:ColorThumb}">

					<Border Background="#00FFFFFF">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition/>
								<ColumnDefinition/>
								<ColumnDefinition/>
							</Grid.ColumnDefinitions>
							<Polygon
							  Name="arrow"
							  Grid.Column="0"
							  Points="0,0 6,3 0,6"
							  Stretch="Fill"
							  Stroke="{TemplateBinding PointerOutlineBrush}"
							  StrokeThickness="{TemplateBinding PointerOutlineThickness}"
							  Fill="Black">
							</Polygon>
							<Polygon
							  Name="arrow2"
							  Grid.Column="2"
							  Points="6,6 0,3 6,0"
							  Stretch="Fill"
							  Stroke="{TemplateBinding PointerOutlineBrush}"
							  StrokeThickness="{TemplateBinding PointerOutlineThickness}"
							  Fill="Black">
							</Polygon>
						</Grid>
					</Border>

					<ControlTemplate.Triggers>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="VerticalSliderLeftThumbStyle" TargetType="{x:Type Thumb}">
		<Setter Property="Foreground" Value="{x:Null}"/>
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
		<Setter Property="Width" Value="21"/>
		<Setter Property="Height" Value="11"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Canvas>
						<!-- Fill Background Area including base border -->
						<!--Path Fill="{TemplateBinding Background}"
							  Data="M 21 11 L 21 0 L 6 0 L 0 5 L 0 6 L 6 11 z"/-->

						<!-- Fill Inner Area -->
						<Path Fill="{TemplateBinding Foreground}"
							  Opacity="0.5"
							  Data="M 19 9 L 19 2 L 6 2 L 2 5.5 L 6 9 z"/>
					</Canvas>
					<ControlTemplate.Triggers>
						<Trigger Property="IsDragging" Value="true">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="VerticalSliderRightThumbStyle" TargetType="{x:Type Thumb}">
		<Setter Property="BorderThickness" Value="0,0,0,0"/>
		<Setter Property="Foreground" Value="{x:Null}"/>
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
		<Setter Property="Width" Value="21"/>
		<Setter Property="Height" Value="11"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Canvas>
						<Path Fill="{TemplateBinding Foreground}"
							  Opacity="0.5"
							  Data="M 2 9 L 2 2 L 15 2 L 19 5.5 L 15 9 "/>
					</Canvas>
					<ControlTemplate.Triggers>
						<Trigger Property="IsDragging" Value="True">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="{x:Type wpf:SpectrumSlider}" TargetType="{x:Type wpf:SpectrumSlider}">
		<Setter Property="Orientation" Value="Vertical"/>
		<Setter Property="Stylus.IsPressAndHoldEnabled"	Value="false"/>
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Minimum" Value="0"/>
		<Setter Property="Maximum" Value="100"/>
		<Setter Property="TickFrequency" Value="0.001" />
		<Setter Property="IsSnapToTickEnabled" Value="True" />
		<Setter Property="IsDirectionReversed" Value="False" />
		<Setter Property="Value" Value="1" />

		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type wpf:SpectrumSlider}">
					<Border Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}"
							Height="{TemplateBinding Height}">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition MinWidth="{TemplateBinding Slider.MinWidth}"/>
							</Grid.ColumnDefinitions>
							<Grid.RowDefinitions>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>

							<Border x:Name="PART_TrackBackground" Width="16">
								<Rectangle x:Name="PART_SpectrumDisplay" Stretch="Fill" VerticalAlignment="Stretch" />
							</Border>

							<Canvas HorizontalAlignment="Center" Width="4">
								<Rectangle
										x:Name="PART_SelectionRange"
										Canvas.Left="1"
										Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
										Width="2.0"
										Visibility="Hidden" />
							</Canvas>

							<Track  Name="PART_Track">
								<Track.DecreaseRepeatButton>
									<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}"
												  Command="Slider.DecreaseLarge"/>
								</Track.DecreaseRepeatButton>
								<Track.IncreaseRepeatButton>
									<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}"
									  Command="Slider.IncreaseLarge"/>
								</Track.IncreaseRepeatButton>
								<Track.Thumb>
									<wpf:ColorThumb
									  x:Name="Thumb"
									  Width="16"
									  Height="8"
									  ThumbColor="{Binding SelectedColor, RelativeSource={RelativeSource TemplatedParent}}" />
								</Track.Thumb>
							</Track>
						</Grid>
					</Border>

					<ControlTemplate.Triggers>
						<!-- Display SelectionRange background -->
						<Trigger Property="IsSelectionRangeEnabled" Value="True">
							<Setter TargetName="PART_SelectionRange"
							   Property="Visibility" Value="Visible"/>
						</Trigger>
						<Trigger Property="Width" Value="Auto">
							<Setter Property="MinWidth" Value="14"/>
						</Trigger>
						<Trigger Property="Height" Value="Auto">
							<Setter Property="MinHeight" Value="100"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>

	</Style>

	<!-- ColorPicker  Styles-->
	<Style x:Key="{x:Type wpf:ColorPicker}" TargetType="{x:Type wpf:ColorPicker}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type wpf:ColorPicker}">

					<StackPanel Orientation="Horizontal" Height="152" Background="{DynamicResource VOColor13}">
								
						<!-- Color picker -->
						<StackPanel Orientation="Vertical" Width="139" Background="Black" Margin="5,5,0,5">

							<StackPanel Orientation="Horizontal">

								<!-- Color box -->
								<Border
									Background="{StaticResource CheckerBrush}"
									BorderBrush="Black"
									BorderThickness="1"
									Width="122"
									Height="122"
									ClipToBounds="True">
									<Border
											Name="PART_ColorDetail"
											Cursor="Cross">
										<Border.Background>
											<DrawingBrush Opacity="{Binding ElementName=opacitySlider,Path=Value}">
												<DrawingBrush.Drawing>
													<DrawingGroup>
														<GeometryDrawing>
															<GeometryDrawing.Geometry>
																<RectangleGeometry Rect="0,0,120,120" />
															</GeometryDrawing.Geometry>
															<GeometryDrawing.Brush>
																<SolidColorBrush Color="{Binding ElementName=PART_ColorSlider, Path=SelectedColor}" />
															</GeometryDrawing.Brush>
														</GeometryDrawing>
														<GeometryDrawing>
															<GeometryDrawing.Geometry>
																<RectangleGeometry Rect="0,0,120,120" />
															</GeometryDrawing.Geometry>
															<GeometryDrawing.Brush>
																<LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0">
																	<GradientStop Offset="0.0" Color="Black" />
																	<GradientStop Offset="1.0" Color="{Binding ElementName=PART_ColorSlider,Path=SelectedColor}" />
																</LinearGradientBrush>
															</GeometryDrawing.Brush>
														</GeometryDrawing>
														<DrawingGroup PresentationOptions:Freeze="True">
															<GeometryDrawing>
																<GeometryDrawing.Geometry>
																	<RectangleGeometry Rect="0,0,120,120" />
																</GeometryDrawing.Geometry>
																<GeometryDrawing.Brush>
																	<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
																		<GradientStop Offset="0.0" Color="White" />
																		<GradientStop Offset="1" Color="Black" />
																	</LinearGradientBrush>
																</GeometryDrawing.Brush>
															</GeometryDrawing>
															<DrawingGroup.OpacityMask>
																<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
																	<GradientStop Offset="0.0" Color="#FF000000" />
																	<GradientStop Offset="1" Color="#00000000" />
																</LinearGradientBrush>
															</DrawingGroup.OpacityMask>
														</DrawingGroup>
													</DrawingGroup>
												</DrawingBrush.Drawing>
											</DrawingBrush>
										</Border.Background>

										<Path
											  Name="PART_ColorMarker"
											  StrokeThickness="2"
											  Cursor="Cross"
											  Fill="Transparent">
											<Path.Data>
												<EllipseGeometry RadiusX="7" RadiusY="7"/>
											</Path.Data>
											<Path.Stroke>
												<SolidColorBrush x:Name="markerBrush" Color="Black"/>
											</Path.Stroke>
										</Path>

									</Border>
								</Border>

								<!-- Slider -->
								<Border BorderBrush="Black" BorderThickness="0,1,1,1" Width="17" Height="122">
									<wpf:SpectrumSlider
									  x:Name="PART_ColorSlider"
									  Value="0"
									  IsMoveToPointEnabled="True"
									  IsSnapToTickEnabled="False"
									  Maximum="360" />
								</Border>

							</StackPanel>

							<Border Background="{StaticResource CheckerBrush}">
								<Rectangle
								  RadiusX="4"
								  RadiusY="4"
								  Width="139"
								  Height="20">
									<Rectangle.Fill>
										<SolidColorBrush Color="{Binding SelectedColor, RelativeSource={RelativeSource TemplatedParent}}" />
									</Rectangle.Fill>
								</Rectangle>
							</Border>

						</StackPanel>
						
						<!-- Informations -->
						<Grid Margin="10,5,5,5">
							<Grid.RowDefinitions>
								<RowDefinition Height="20"/>
								<RowDefinition Height="20"/>
								<RowDefinition Height="20"/>
								<RowDefinition Height="20"/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="30"/>
								<ColumnDefinition Width="50"/>
							</Grid.ColumnDefinitions>

							<TextBlock Text="R : " Grid.Row="0"/>
							<TextBlock Text="G : " Grid.Row="1"/>
							<TextBlock Text="B : " Grid.Row="2"/>
							<TextBlock Text="A : " Grid.Row="3"/>

							<TextBox x:Name="txtR" Grid.Row="0" Grid.Column="1" Text="{Binding R, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center"/>
							<TextBox x:Name="txtG" Grid.Row="1" Grid.Column="1" Text="{Binding G, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center"/>
							<TextBox x:Name="txtB" Grid.Row="2" Grid.Column="1" Text="{Binding B, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center"/>
							<TextBox x:Name="txtA" Grid.Row="3" Grid.Column="1" Text="{Binding A, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center"/>

						</Grid>
						
					</StackPanel>

				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>